package me.helllp.dake.iam.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import me.helllp.dake.common.exception.DakeDataExistedException;
import me.helllp.dake.common.exception.DakeException;
import me.helllp.dake.core.bean.DakeAuthAccount;
import me.helllp.dake.iam.core.dto.TenantDto;
import me.helllp.dake.iam.core.mapper.DakeTenantMapper;
import me.helllp.dake.iam.core.po.DakeAccount;
import me.helllp.dake.iam.core.po.DakeTenant;
import me.helllp.dake.iam.core.service.ITenantService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class TenantService implements ITenantService {
    @Autowired
    private DakeTenantMapper tenantMapper;

    @Override
    public Long createTenant(DakeAuthAccount account, TenantDto tenantDto) throws DakeDataExistedException {
        QueryWrapper<DakeTenant> wrapper = new QueryWrapper();
        wrapper.eq("TENANT_NAME", tenantDto.getTenantName()).or().eq("TENANT_CODE", tenantDto.getTenantCode());
        DakeTenant info = tenantMapper.selectOne(wrapper);
        if (ObjectUtils.isNotEmpty(info)) {
            throw new DakeDataExistedException();
        }

        // 创建数据

        return null;
    }

    @Override
    public Boolean deleteTenant(DakeAuthAccount account, Long tenantId) {
        return null;
    }

    @Override
    public Boolean modifyTenant(DakeAuthAccount account, TenantDto tenantDto) {
        return null;
    }
}
